﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	导渗系统
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="dolphincontainer">
	    <div id="dolphinnav">
	        <ul class="top_tab">
	            <li><a href="/Stack/Index"><span>堆场管理</span></a></li>
                <li><a href="/Stack/Edit/<%=ViewData["id"] %>"><span>基本信息</span></a></li>
                <li><a href="/Stack/Weather/<%=ViewData["id"] %>"><span>气象信息</span></a></li>
                <li><a href="/Stack/Stack/<%=ViewData["id"] %>"><span>堆场信息</span></a></li>
                <li><a href="/Stack/Pool/<%=ViewData["id"] %>t"><span>调节水池</span></a></li>
                <li><a href="/Stack/Material/<%=ViewData["id"] %>"><span>材料信息</span></a></li>
                <li><a href="/Stack/Settle/<%=ViewData["id"] %>"><span>沉降模型</span></a></li>
                <li><a href="/Stack/Piezometer/<%=ViewData["id"] %>"><span>测压井测压仪</span></a></li>
                <li><a href="javascript:return(false);" class="current"><span>导渗系统</span></a></li>
                <li><a href="/Position/List?type=1&stackId=<%=ViewData["id"] %>"><span>上传图片</span></a></li>
	        </ul>
	    </div>
	</div>

    
    <% 
    Dictionary<Drain_system_basic_info, List<Drain_system_outlet_info>> drainOutlets = (Dictionary<Drain_system_basic_info, List<Drain_system_outlet_info>>)ViewData["drainOutlets"];
    
    int drainNum = drainOutlets.Count;

    using (Html.BeginForm("Drain", "Stack", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
    %>
        <%= Html.ValidationSummary(true) %>
        <%= Html.Hidden("id", (int)ViewData["id"])%>
        <%
           bool result = (bool)ViewData["success"];
           if(result){ 
        %>
           <div class="tips_area">导渗系统更新成功</div>
        <%
        }
        %>
    
    
    <fieldset class="tf_style" style="width:96%;">
        <legend>导渗系统</legend>
        
        
        <div id="drains">
        
            <%
            int i = 0;
            foreach (KeyValuePair<Drain_system_basic_info, List<Drain_system_outlet_info>> drain in drainOutlets)
            {
            %>

                <table id="drain<%=i + 1 %>" cellpadding="4" cellspacing="0" class="com_detail_table2" style="margin-top:8px;">
                    <tr>
                        <td class="lab" style="width:100px;">导渗系统高程：</td>
                        <td style="width:640px;"><input type="text" size="8" name="El<%=i+1 %>" value="<%=drain.Key.El %>"/></td>
                    </tr>

                    <tr>
                        <td class="lab">出水口信息：</td>
                        <td><input type="button" value="增加出水口" onclick="addOutlet(<%=i+1 %>);" /></td>
                    </tr>

                    <tr>
                        <td colspan="2">
                            
                            <table id="outlets_<%=i+1 %>" cellpadding="2" cellspacing="0" class="subtable2" style="width:100%; text-align:center;">

                                <tr>
                                    <th style="text-align:center;">编号</th>
                                    <th style="text-align:center;">分组</th>
                                    <th style="text-align:center;">对应导渗段</th>
                                    <th style="text-align:center;">是否为导渗段仅有出水口</th>
                                    <th style="text-align:center;">是否为溢流出水口</th>
                                    <th style="text-align:center;">是否提供给堆场进行数据录入</th>
                                    <th style="text-align:center;">是否可以正常监测</th>
                                    <th style="text-align:center;">操作</th>
                                </tr>
                                <%
                                    List<Drain_system_outlet_info> outlets = drain.Value;
                                    int j = 0;
                                    if (outlets != null && outlets.Count > 0)
                                    {
                                        foreach (Drain_system_outlet_info outlet in outlets)
                                        {
                                %>
                                <tr id="outlet_<%=i + 1 %>_<%=j + 1 %>">
                                    <td><%=j + 1 %></td>
                                    <td><input type="text" size="5" name="Drain_outlet_group_no_<%=i+1 %>_<%=j+1 %>" value="<%=outlet.Drain_outlet_group_no %>" /></td>
                                    <td><input type="text" size="6" name="Drain_outlet_section_no_<%=i+1 %>_<%=j+1 %>" value="<%=outlet.Drain_outlet_section_no %>" /></td>
                                    <td><input type="checkbox" name="Is_sole_outlet_<%=i+1 %>_<%=j+1 %>" value="1" <%if(outlet.Is_sole_outlet==1){ %>checked="checked"<%} %> /></td>
                                    <td><input type="checkbox" name="Is_seepage_outlet_<%=i+1 %>_<%=j+1 %>" value="1" <%if(outlet.Is_seepage_outlet==1){ %>checked="checked"<%} %> /></td>
                                    <td><input type="checkbox" name="Is_open_for_input_<%=i+1 %>_<%=j+1 %>" value="1" <%if(outlet.Is_open_for_input==1){ %>checked="checked"<%} %> /></td>
                                    <td><input type="checkbox" name="Is_In_Normal_Use_<%=i+1 %>_<%=j+1 %>" value="1" <%if(outlet.Is_In_Normal_Use==1){ %>checked="checked"<%} %> /></td>
                                    <td><a href="javascript:void(0);" onclick="removeOutlet(<%=i + 1 %>, <%=j + 1 %>);">删除</a></td>
                                </tr>
                                <%
                                    j++;
                                        }
                                    }
                                %>

                            </table>
                            <input type="hidden" id="outletNum_<%=i+1 %>" name="outletNum_<%=i+1 %>" value="<%=j %>" />

                        </td>
                    </tr>

                    <tr>
                        <td class="lab">上传图片：</td>
                        <td>
                            <input type="file" name="Pic_filepath_<%=i+1 %>" size="68" /><%if (!string.IsNullOrEmpty(drain.Key.Pic_filepath)){%> 
                            <label class="icon_12"><a href="<%=Url.Content(drain.Key.Pic_filepath) %>" target="_blank">查看原图</a><%} %></label>
                        </td>
                    </tr>

                </table>

            <%
                i++;
            }
            %>
            <input type="hidden" id="drainNum" name="drainNum" value="<%=i %>" />
        </div>

        <p><input type="button" value="增加导渗系统" onclick="addDrain();" /></p>

    </fieldset>
      
    <div class="submit_btn_area" style="margin-left:160px;">
        <input type="submit" value="提 交" />
    </div>
    <% } %>

    <script type="text/javascript"" language="javascript">
        function getDrainInnerHtml(drainNum)
        {
            //var htmlStr = "<table id='drain" + drainNum + "' cellpadding='4' cellspacing='0' class='com_detail_table2' style='margin-top:8px;'><tr><td class='lab' style='width:100px;'>导渗系统高程：</td><td style='width:640px;'><input type='text' size='8' name='El" + drainNum + "' value=''/></td></tr><tr><td class='lab'>出水口信息：</td><td><input type='button' value='增加出水口' onclick='addOutlet(" + drainNum + ");' /></td></tr><tr><td><table width='100%' style='background-color:White' id='outlets_" + drainNum + "'><tr height='25px'><td>编号</td><td>分组</td><td>对应导渗段</td><td>是否为导渗段仅有出水口</td><td>是否为溢流出水口</td><td>是否提供给堆场进行数据录入</td><td>是否可以正常监测</td><td>删除</td></tr></table><input type='hidden' id='outletNum_" + drainNum + "' name='outletNum_" + drainNum + "' value='0' /></td></tr><tr height='30px'><th>上传图片：<input style='margin-left:20px' type='file' name='Pic_filepath_" + drainNum + "' size='80' /></th></tr></table>";

            var htmlStr = "<table id='drain" + drainNum + "' cellpadding='4' cellspacing='0' class='com_detail_table2' style='margin-top:8px;'><tr><td class='lab' style='width:100px;'>导渗系统高程：</td><td style='width:640px;'><input type='text' size='8' name='El" + drainNum + "' value=''/></td></tr><tr><td class='lab'>出水口信息：</td><td><input type='button' value='增加出水口' onclick='addOutlet(" + drainNum + ");' /></td></tr><tr><td colspan='2'><table id='outlets_" + drainNum + "' cellpadding='2' cellspacing='0' class='subtable2' style='width:100%; text-align:center;'><tr><th style='text-align:center;'>编号</th><th style='text-align:center;'>分组</th><th style='text-align:center;'>对应导渗段</th><th style='text-align:center;'>是否为导渗段仅有出水口</th><th style='text-align:center;'>是否为溢流出水口</th><th style='text-align:center;'>是否提供给堆场进行数据录入</th><th>是否可以正常监测</th><th style='text-align:center;'>操作</th></tr></table><input type='hidden' id='outletNum_" + drainNum + "' name='outletNum_" + drainNum + "' value='0' /></td></tr><tr><td class='lab'>上传图片：</td><td><input type='file' name='Pic_filepath_" + drainNum + "' size='68' /></td></tr></table>";


	        return htmlStr;
        }        
        
        function addDrain() {
            var drainNum = document.getElementById("drainNum").value;
            drainNum++;
            $("#drains").append(getDrainInnerHtml(drainNum));
            document.getElementById("drainNum").value = drainNum;
        }

        function removeDrain(drainNo) {
            $("#drain" + drainNo).remove();
            var drainNum = document.getElementById("drainNum").value;
            drainNum--;
            document.getElementById("drainNum").value = drainNum;
        }

        function getOutletInnerHtml(drainNo, outletNum) {
            var htmlStr = "<tr id='outlet_" + drainNo + "_" + outletNum + "'><td>" + outletNum + "</td><td><input type='text' size='5' name='Drain_outlet_group_no_" + drainNo + "_" + outletNum + "' value='' /></td><td><input type='text' size='6' name='Drain_outlet_section_no_" + drainNo + "_" + outletNum + "' value='' /></td><td><input type='checkbox' name='Is_sole_outlet_" + drainNo + "_" + outletNum + "' value='1' /></td><td><input type='checkbox' name='Is_seepage_outlet_" + drainNo + "_" + outletNum + "' value='1' /></td><td><input type='checkbox' name='Is_open_for_input_" + drainNo + "_" + outletNum + "' value='1' /></td><td><input type='checkbox' name='Is_In_Normal_Use_" + drainNo + "_" + outletNum + "' value='1' /></td><td><a href='javascript:void(0);' onclick='removeOutlet(" + drainNo + ", " + outletNum + ");'>删除</a></td></tr>";

            return htmlStr;
        }

        function addOutlet(drainNo) {
            var outletNum = document.getElementById("outletNum_" + drainNo).value;
            outletNum++;
            $("#outlets_" + drainNo).append(getOutletInnerHtml(drainNo, outletNum));
            document.getElementById("outletNum_" + drainNo).value = outletNum;
        }

        function removeOutlet(drainNo, outletNo) {
            $("#outlet_" + drainNo + "_" + outletNo).remove();
            var outletNum = document.getElementById("outletNum_" + drainNo).value;
            outletNum--;
            document.getElementById("outletNum_" + drainNo).value = outletNum;
        }
    </script>
</asp:Content>
